import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type AdminResult = {
  success: boolean;
  data: {
    /** 管理员ID */
    adminId: number;
    /** 管理员编码 */
    adminCode: string;
    /** 管理员姓名 */
    adminName: string;
  };
};

/** 登录并获取token */
export const login = (data?: object) => {
  return http.request<string>("post", baseUrlApi("/admin/login"), {
    data
  });
};

/** 获取管理员信息 */
export const getAdminInfo = (data: { adminCOde: string }) => {
  return http.request<AdminResult>("post", baseUrlApi("/admin/info"), {
    data
  });
};

/** 注册管理员 */
export const registerAdmin = (data: object) => {
  return http.request("post", baseUrlApi("/admin/register"), {
    data
  });
};
